﻿using System.Xml.Linq;
using Schema = QASPRibbon.RibbonSchema;

namespace QASPRibbon.Controls
{
    ///<summary>
    ///</summary>
    public class RibbonSpinnerUnit : RibbonElement
    {
        #region Properties

        ///<summary>
        ///</summary>
        public decimal MinimumValue
        {
            get { return _minimumValue; }
            set { _minimumValue = value; }
        }

        ///<summary>
        ///</summary>
        public decimal MaximumValue
        {
            get { return _maximumValue; }
            set { _maximumValue = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public int DecimalDigits
        {
            get { return _decimalDigits; }
            set { _decimalDigits = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public double Interval
        {
            get { return _interval; }
            set { _interval = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        public string Value
        {
            get { return _value; }
            set { _value = value; }
        }

        ///<summary>
        ///</summary>
        public bool IsDefault
        {
            get { return _isDefault; }
            set { _isDefault = value; }
        }

        #endregion

        #region Internal

        internal override string XmlTag
        {
            get { return Schema.Unit; }
        }

        #endregion

        #region Private

        #endregion

        private decimal _minimumValue;
        private decimal _maximumValue = 100;
        private int _decimalDigits;
        private double _interval = 1;
        private string _value = string.Empty;
        private bool _isDefault = true;

        internal override XElement AsXElement()
        {
            var xml = new XElement(XmlTag);
            xml.Add(new XAttribute(Schema.Name, Title));
            xml.Add(new XAttribute(Schema.MinimumValue, MinimumValue));
            xml.Add(new XAttribute(Schema.MaximumValue, MaximumValue));
            xml.Add(new XAttribute(Schema.DecimalDigits, DecimalDigits));
            xml.Add(new XAttribute(Schema.Interval, Interval));
            xml.Add(new XElement(Schema.UnitAbbreviation, new XAttribute(Schema.Value, Value)));
            return xml;
        }
    }
}
